﻿Imports Tirailleur

Friend Class cMetricGridCoordinate

    Implements IMetricCoordinateTwoDimensional

    Private mMetricLocationX As Double
    Private mMetricLocationY As Double

    Friend Sub New(ByVal LocationX As Double, ByVal LocationY As Double)
        mMetricLocationX = LocationX
        mMetricLocationY = LocationY
    End Sub

    Friend ReadOnly Property LocationX() As Double Implements IMetricCoordinateTwoDimensional.LocationX
        Get
            Return mMetricLocationX
        End Get
    End Property

    Friend ReadOnly Property LocationY() As Double Implements IMetricCoordinateTwoDimensional.LocationY
        Get
            Return mMetricLocationY
        End Get
    End Property

    Friend Function IsSameAs(ByVal OtherCoordinate As Tirailleur.IMetricCoordinateTwoDimensional) As Boolean Implements IMetricCoordinateTwoDimensional.IsSameAs

        Const Tolerance As Double = 0.001 'one millimetre
        Dim IsEqual As Boolean

        IsEqual = False

        If Math.Abs(mMetricLocationX - OtherCoordinate.LocationX) < Tolerance Then
            If Math.Abs(mMetricLocationY - OtherCoordinate.LocationY) < Tolerance Then
                IsEqual = True
            End If
        End If

        Return IsEqual

    End Function

End Class
